<table border="0" cellspacing="1" cellpadding="1">  
  <tr>
    <th>
    </th>  
    <th>状态</th>    
    <th>内容</th>
    <th>尝试</th>
    <th>最后异常</th>
    <th>创建于</th>
    <th>发送于</th>
    <th>
      操作
      <div id='user_<%= @user.id %>_menu' class='menu' style='display:none'>
        <div>
          <%= link_to_remote '发短信给Ta',
                :update => "user_#{@user.id}_last_sms",
                :url => new_sm_user_url(@user),
                :method => :get
          %>
          <%= link_to_remote '刷新',
                :update => "user_#{@user.id}_last_sms",
                :url => last_sms_user_url(@user),
                :method => :get
          %>  
        </div>        
      </div>
    </th>
  </tr>
  <% @user.last_sms.each_with_index do |sm,index| %>
  <tr>
    <td align='right'><%= index + 1 %>.</td>
    <td><%= t sm.status %></td>
    <td title='<%= sm.content %>'><%= truncate sm.content, :length => 25 %></td>
    <td align='right'>
      <%= sm.trying_count %>次
    </td>
    <td align='center' title='<%= sm.exception if sm.exception.present? %>'>
      <%= sm.exception.blank? ? '--' : truncate(sm.exception, :length => 20)  %>
    </td>
    <td><%= time_ago_in_words sm.created_at %>前</td>
    <td><%= sm.sent? ? "#{time_ago_in_words(sm.updated_at)}前" : '--' %></td>
    <td>
      <%= link_to_remote '重发', 
            :url => resend_sm_url(sm),
            :method => :put,
            :loading => small_loading("resend_sm_#{sm.id}_link", :only_img => true),
            :complete => remote_function(
              :update => "user_#{@user.id}_last_sms",
              :url => last_sms_user_url(@user.id),
              :method => :get
            ),
            :html => {
              :id => "resend_sm_#{sm.id}_link"
            }
      %>
      <%= link_to_remote '删除',
            :url => sm_url(sm),
            :method => :delete,
            :loading => small_loading("destroy_sm_#{sm.id}_link", :only_img => true),
            :complete => remote_function(
              :update => "user_#{@user.id}_last_sms",
              :url => last_sms_user_url(@user.id),
              :method => :get
            ),
            :html => {
              :id => "destroy_sm_#{sm.id}_link"
            }
       %>
    </td>
  </tr>
  <% end %>
  <% if not @user.last_sms.any? %>
  <tr>
    <td colspan='8' align='center'>无短信</td>
  </tr>
  <% end %>
</table>